package edu.scau.pro.hotel.service.impl;

import edu.scau.pro.hotel.entity.HotelReserveDetail;
import edu.scau.pro.hotel.mapper.HotelReserveDetailMapper;
import edu.scau.pro.hotel.service.IHotelReserveDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotelReserveDetail)表服务实现类
 *
 * @author CJW
 * @since 2022-03-13 15:48:29
 */
@Service("hotelReserveDetailService")
public class HotelReserveDetailServiceImpl implements IHotelReserveDetailService {
    @Resource
    private HotelReserveDetailMapper hotelReserveDetailMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param reserveDetailId 主键
     * @return 实例对象
     */
    @Override
    public HotelReserveDetail queryById(Integer reserveDetailId) {
        return this.hotelReserveDetailMapper.queryById(reserveDetailId);
    }

    /**
     * 查询指定行
     *
     * @param hotelReserveDetail 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotelReserveDetail> queryAll(HotelReserveDetail hotelReserveDetail) {
        return this.hotelReserveDetailMapper.queryAll(hotelReserveDetail);
    }

    /**
     * 新增数据
     *
     * @param hotelReserveDetail 实例对象
     * @return 实例对象
     */
    @Override
    public HotelReserveDetail insert(HotelReserveDetail hotelReserveDetail) {
        this.hotelReserveDetailMapper.insert(hotelReserveDetail);
        return hotelReserveDetail;
    }

    /**
     * 修改数据
     *
     * @param hotelReserveDetail 实例对象
     * @return 实例对象
     */
    @Override
    public HotelReserveDetail update(HotelReserveDetail hotelReserveDetail) {
        this.hotelReserveDetailMapper.update(hotelReserveDetail);
        return this.queryById(hotelReserveDetail.getReserveDetailId());
    }

    /**
     * 通过主键删除数据
     *
     * @param reserveDetailId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer reserveDetailId) {
        return this.hotelReserveDetailMapper.deleteById(reserveDetailId) > 0;
    }
}
